const path = require('path')
const resolve = (dir) => path.join(__dirname, dir)
const name = '影像云存储共享' // page title
module.exports = {
	publicPath: './',
	outputDir: 'dist',
	assetsDir: 'assets',
	indexPath: 'index.html',
	filenameHashing: true,
	pages: {
		index: {
			entry: 'src/main.js',
			template: 'public/index.html',
			filename: 'index.html',
			title: '影像云存储共享系统',
			chunks: [
				'chunk-vendors',
				'chunk-common',
				'index'
			]
		}
	},
	lintOnSave: process.env.NODE_ENV === 'development',
	productionSourceMap: false, // 除去.map文件
	devServer: {
		// host: 'localhost',
		port: '8080',
		hot: false,
		open: true,
		// overlay: {
		//   warning: false,
		//   error: true
		// }
		proxy: {
			'/Common': {
				target: 'http://192.168.1.173:8710/api-idcas',
				changeOrigin: true,
				pathRewrite: {
					'^/Common': ''
				}
			}
		}
	},
	configureWebpack: {
		/*
     * provide the app's title in webpack's name field, so that
     * it can be accessed in index.html to inject the correct title.
     */
		name,
		resolve: { alias: { '@': resolve('src') } }
	},
	configureWebpack: (config) => {
		if (process.env.NODE_ENV === 'production') {
			config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true
		}
	},
	pluginOptions: {
		'style-resources-loader': {
			preProcessor: 'less',
			patterns: []
		}
	},
	pluginOptions: {
		'style-resources-loader': {
			preProcessor: 'less',
			patterns: [
				path.resolve(__dirname, 'src/style/variable.less')
			]
		}
	},
	chainWebpack: (config) => {
		config.resolve.alias
			.set('assets', resolve('src/assets'))
			.set('components', resolve('src/components'))
			.set('layout', resolve('src/layout'))
			.set('style', resolve('src/style'))
			.set('api', resolve('src/api'))
			.set('utils', resolve('src/utils'))
			.set('static', resolve('src/static'))
	}

	/*
   * chainWebpack (config) {
   *   config.module
   *     .rule('svg')
   *     .exclude.add(resolve('src/assets/svg/icons')) // icons存放地（svg放的地方）
   *     .end()
   *   config.module
   *     .rule('icons')
   *     .test(/\.svg$/)
   *     .include.add(resolve('src/assets/svg/icons')) // icons存放地（svg放的地方）
   *     .end()
   *     .use('svg-sprite-loader')
   *     .loader('svg-sprite-loader')
   *     .options({
   *       symbolId: 'icon-[name]'
   *     })
   *     .end()
   * }
   */
}
